package com.ruoyi.web.controller.production.plug;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.plug.PlugAmount;
import com.ruoyi.production.service.plug.IPlugAmountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 穴盘量Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/plugAmount")
@Api(value = "穴盘量",tags = "穴盘量相关API")
public class PlugAmountController extends BaseController
{
    @Autowired
    private IPlugAmountService plugAmountService;

    /**
     * 查询穴盘量列表
     */
    @PreAuthorize("@ss.hasPermi('production:plugAmount:list')")
    @GetMapping("/list")
    public TableDataInfo list(PlugAmount plugAmount)
    {
        startPage();
        List<PlugAmount> list = plugAmountService.selectPlugAmountList(plugAmount);
        return getDataTable(list);
    }

    /**
     * 导出穴盘量列表
     */
    @PreAuthorize("@ss.hasPermi('production:plugAmount:export')")
    @Log(title = "穴盘量", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PlugAmount plugAmount)
    {
        List<PlugAmount> list = plugAmountService.selectPlugAmountList(plugAmount);
        ExcelUtil<PlugAmount> util = new ExcelUtil<PlugAmount>(PlugAmount.class);
        return util.exportExcel(list, "穴盘量数据");
    }

    /**
     * 获取穴盘量详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:plugAmount:query')")
    @GetMapping(value = "/{plugAmountId}")
    public AjaxResult getInfo(@PathVariable("plugAmountId") Long plugAmountId)
    {
        return AjaxResult.success(plugAmountService.selectPlugAmountById(plugAmountId));
    }

    /**
     * 新增穴盘量
     */
    @PreAuthorize("@ss.hasPermi('production:plugAmount:add')")
    @Log(title = "穴盘量", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody PlugAmount plugAmount)
    {
        return toAjax(plugAmountService.insertPlugAmount(plugAmount));
    }

    /**
     * 修改穴盘量
     */
    @PreAuthorize("@ss.hasPermi('production:plugAmount:edit')")
    @Log(title = "穴盘量", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody PlugAmount plugAmount)
    {
        return toAjax(plugAmountService.updatePlugAmount(plugAmount));
    }

    /**
     * 删除穴盘量
     */
    @PreAuthorize("@ss.hasPermi('production:plugAmount:remove')")
    @Log(title = "穴盘量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{plugAmountIds}")
    public AjaxResult remove(@PathVariable Long[] plugAmountIds)
    {
        return toAjax(plugAmountService.deletePlugAmountByIds(plugAmountIds));
    }
}
